<template>
  <div class="home-item" @click="itemClick">
    <div class="item-inner">
      <div class="cover">
        <img :src="itemData?.image.url" alt="">
      </div>
      <div class="infos">
        <div class="location">
          <img src="@/assets/img/home/location.png" alt="">
          <span class="location-word">{{ itemData.location }}</span>
        </div>
        <div class="name">{{ itemData.houseName }}</div>
        <div class="summary">{{ itemData.summaryText }}</div>
        <div class="price">
          <div class="new">￥{{ itemData.finalPrice}}</div>
          <div class="old">￥{{ itemData.productPrice}}</div>
          <div class="tip"> {{ itemData?.priceTipBadge?.text}} </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
const router = useRouter()
 const props = defineProps({
    itemData: {
      type:Object,
      default: ()=> ({})
    }
  })
  const itemClick = () => {
    console.log(props.itemData.houseId)
    router.push("/detail/"+ props.itemData.houseId)
  }
</script>

<style lang="less" scoped>
.home-item {
  width: 50%;
  .item-inner {
    margin: 5px;
    border-radius: 6px;
    overflow: hidden;
    .cover img{
      width: 100%;
    }
    .infos {
      margin: 8px 10px;
      .location {
        display: flex;
        align-items: center;
        img{
          width: 20px;
        }
        .location-word {
          color: #666;
        }
      }
      .name {
        display: -webkit-box;
        overflow: hidden;
        margin-top: 3px;
        font-size: 14px;
        text-overflow: ellipsis;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
      .summary {
        margin: 3px 0;
        color: #333;
      }
      .price {
        display: flex;
        align-items: center;
        .new {
          color: gold;
          font-size: 14px;
        }
        .old{
          color: #666;
          font-size: 12px;
          text-decoration: line-through;
        }
        .tip {
          color: #fff;
          margin-left: 5px;
          padding: 0 5px;
          background-color: orange;
          border-radius: 8px;
        }
      }
    }
  }
}
</style>
